package com.luying.controller.controller;

import com.luying.pojo.*;
import com.luying.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 教师相关controller
 */
@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    /**
     * 德育成绩录入筛选项下拉
     *
     * @param id
     * @return
     */
    @GetMapping("/screen")
    public Result screen(@RequestParam("id") Integer id) {
        return Result.ok(teacherService.getAllScreen(id));

    }
    @PostMapping("/add")
    public Result addScore(@RequestBody StudentScore studentScore){
        teacherService.addScore(studentScore);
        return Result.ok();
    }
    @GetMapping("/class")
    public Result teacherClass(@RequestParam("id") Integer id) {
        return Result.ok(teacherService.teacherClass(id));

    }
    @GetMapping("/year")
    public Result year() {
        return Result.ok(teacherService.year());

    }
    @GetMapping("/subjectAndStudent")
    public Result subjectClass(@RequestParam("teacher_id") Integer teacherId,@RequestParam("class_id")Integer classId) {
        return Result.ok(teacherService.subjectAndStudent(teacherId,classId));

    }
    @PostMapping("/score/list")
    public Result scoreList(@RequestBody ScorePageQuery pageQuery){
        PageResult pageResult = teacherService.scoreList(pageQuery);
        return Result.ok(pageResult);
    }

    @GetMapping("/moral/screen")
    public Result moralScreen() {
        return Result.ok(teacherService.moralScreen());

    }
    @PostMapping("/moral/add")
    public Result moralAdd(@RequestBody StudentMoralScore studentMoralScore) {
        return Result.ok(teacherService.moralAdd(studentMoralScore));

    }
    @PostMapping("/moral/list")
    public Result moralList(@RequestBody ScorePageQuery pageQuery) {
        return Result.ok(teacherService.moralList(pageQuery));

    }
}
